<template>
  <el-card class="box-card" style="width: 1180px">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="微信配置" name="first">
        <el-form ref="form" :model="wechat" label-width="140px">
          <el-form-item label="微信支付商户">
            <el-input v-model="wechat.wcCommercialTenant"></el-input>
          </el-form-item>
          <el-form-item label="微信支付Appid">
            <el-input v-model="wechat.wcCommercialAppId"></el-input>
          </el-form-item>
          <el-form-item label="微信商户账户">
            <el-input v-model="wechat.wcCommercialAccount"></el-input>
          </el-form-item>
          <el-form-item label="微信支付密钥">
            <el-input v-model="wechat.wcPayKeys"></el-input>
          </el-form-item>
          <el-form-item label="微信商户密钥">
            <el-input v-model="wechat.wcCommercialKeys"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmitWechat">保存</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="支付宝配置" name="second">
        <el-form ref="form" :model="alipay" label-width="140px">
          <el-form-item label="支付宝名称">
            <el-input v-model="alipay.asName"></el-input>
          </el-form-item>
          <el-form-item label="合作身份者id">
            <el-input v-model="alipay.asPartnerId"></el-input>
          </el-form-item>
          <el-form-item label="MD5安全校验码">
            <el-input v-model="alipay.asMd5"></el-input>
          </el-form-item>
          <el-form-item label="支付方式私有密钥">
            <el-input v-model="alipay.asPrivateKeys"></el-input>
          </el-form-item>
          <el-form-item label="格式化方式">
            <el-input v-model="alipay.asFormatting"></el-input>
          </el-form-item>
          <el-form-item label="字符编码">
            <el-input v-model="alipay.asCharacter"></el-input>
          </el-form-item>
          <el-form-item label="支付方式">
            <el-input v-model="alipay.asPayMethod"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmitAlipay">保存</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="短信参数配置" name="third">
        <el-form ref="form" :model="msg" label-width="140px">
          <el-form-item label="模版ID">
            <el-input v-model="msg.msTemplateId"></el-input>
          </el-form-item>
          <el-form-item label="短信用户名">
            <el-input v-model="msg.msMsgusername"></el-input>
          </el-form-item>
          <el-form-item label="短信密码">
            <el-input v-model="msg.msPassword"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmitMsg">保存</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
    </el-tabs>
  </el-card>
</template>
<style>
</style>
<script>
export default {
  data() {
    return {
      activeName: "first",
      wechat: {},
      alipay: {},
      msg:{},
    };
  },
  methods: {
    loadWechat() {
      this.$axios.get("/admin/system/queryWechatSet").then((res) => {
        this.wechat = res.data.data;
      });
    },
    onSubmitWechat() {
      this.$axios.put("/admin/system/updateWechatSet", this.wechat).then((res) => {
        if (res.data.code == 200) {
          alert("保存成功");
        } else {
          alert("修改失败");
        }
      });
    },
    loadAlipay() {
      this.$axios.get("/admin/system/queryAliSet").then((res) => {
        this.alipay = res.data.data;
      });
    },
    onSubmitAlipay() {
      this.$axios.put("/admin/system/updateAliset", this.alipay).then((res) => {
        if (res.data.code == 200) {
          alert("保存成功");
        } else {
          alert("修改失败");
        }
      });
    },
    loadMsg() {
      this.$axios.get("/admin/system/queryMsgSet").then((res) => {
        this.msg = res.data.data;
      });
    },
    onSubmitMsg() {
      this.$axios.put("/admin/system/updateMsgSet", this.msg).then((res) => {
        if (res.data.code == 200) {
          alert("保存成功");
        } else {
          alert("修改失败");
        }
      });
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
  },
  mounted() {
    this.loadWechat();
    this.loadAlipay();
    this.loadMsg();
  },
};
</script>